package thread;

import java.util.Scanner;

public class Demo21 {

    private volatile static int flag = 0;

    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            while (flag == 0) {
//                try {
//                    Thread.sleep(1);
//                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);
//                }
            }
            System.out.println("t1 end");
        });
        Thread t2 = new Thread(()->{
            Scanner scanner = new Scanner(System.in);
            System.out.print("flag = ");
            flag = scanner.nextInt();
        });

        t1.start();
        t2.start();
    }
}
